
<template>
  <div class="my-prize" v-title data-title="我的奖品">
    <!-- <my-header main-text="我的奖品" bg-color="#fff" text-color="#000">
        <img slot="" src="../../assets/left-gray.svg">
    </my-header> -->
    <magic-header v-if="!isWxPublic&&!isWeb" titleName="我的奖品"></magic-header>
    <div class="body" id="body">
      <div class="content_top">
        <div class="content_body">
          <span class="title">我的奖品</span>
          <ul class="prizeList">
            <li v-for="(item, index) in awardList" :key="index">
              <div class="prLi_left">
                <p class="pr_con">{{ item.name || '奖品'}}</p>
                <p class="pr_time">中奖时间：{{ item.happenDate | formatTime }}</p>
              </div>
            </li>
            <li>
              <div class="btn_group">
                <button class="go_on" v-tap="{methods: comeBack}">继续抽奖</button>
                <button class="use" v-tap="{methods: goProduct}">立即使用</button>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="bottom_foot">
        <h5 class="bottom_foot_title">活动规则</h5>
        <!-- <div v-for="(item,index) in rule" :key="index">{{item}}</div> -->
        <rule :titleShow="false" :value="ruleData" />
      </div>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import magicHeader from 'components/magicHeader'
import dataServices from 'services/event/eve_myPrize'
import rule from 'components/rule'
let isred = true
export default {
  components: {
    magicHeader,
    rule
  },
  data() {
    return {
      awardList: [],
      ruleData: '',
      isRed: isred,
      isWxPublic: false,
      isWeb: false
    }
  },
  created() {
    //判断微信环境
    if (this.$.env === "wxPublic" || this.$.env === "webOrWechat") {
      this.isWxPublic = true
    }
    
    //判断是否在app
    if (this.$route.params.isWeb !== undefined) {
      this.isWeb = this.$route.params.isWeb
    }
    //获取奖品列表 活动规则
    dataServices.QueryAward.bind(this)({
      methodName: 'QueryAward',
      index: '0',
      count: '100',
      id: this.$route.params.activityId
    }, res => {
      this.awardList = res.awardList
      this.ruleData = res.rule
    }, err => {
      this.$.toast(err);
    })
  },
  methods: {
    comeBack() {
      window.history.go(-1)
    },
    goProduct() {
      if (this.isWxPublic) {
        this.$.toast('请到我的卡券查看')
      } else {
        this.$.toast('请到我的卡券查看')
      }
    }
  },
  filters: {
    formatTime: function (value) {
      return value.split(' ')[0]
    }
  },
  mounted() {
    var that = this
    window.scrollTo(0, 0)
  }
}
</script>
<style scoped>
.my-prize {
  min-height: 100vh;
  padding-bottom: 20px;
  background-color: #102135;
}
.body {
  background: url(../../assets/border.png) no-repeat;
  background-size: 100%;
  background-color: #102135;
  height: calc(100% - 50px);
}
.content_top {
  width: 90%;
  margin: auto;
  padding-top: 8%;
}
.content_body {
  width: 88%;
  margin: auto;
  background-color: #fff;
  padding-top: 5px;
}
.content_body .title {
  text-align: center;
  display: block;
  background-color: #ff5d5a;
  width: 60%;
  padding: 6px 20px;
  border-radius: 50px;
  color: #fff;
  margin: auto;
  font-size: 16px;
  margin-top: 10px;
  margin-bottom: 20px;
}
.prizeList {
  max-height: calc(100vh - 260px);
  overflow: auto;
}
.prizeList li {
  height: 50px;
  border-bottom: 2px solid #ebe8bb;
  margin-left: 6%;
  margin-top: 15px;
}
.prLi_left {
  /*width: 70%;*/
  float: left;
  padding-left: 18%;
  height: 40px;
  line-height: 20px;
  background: url(../../assets/hongbaoBG.png) no-repeat left 8% center;
  background-size: 10%;
}
.prLi_right {
  width: 30%;
  float: right;
  height: 40px;
  line-height: 40px;
  font-size: 15px;
  color: #000;
  text-align: right;
  padding-right: 8%;
}
.pr_con {
  font-size: 15px;
  font-weight: 600;
}
.pr_time {
  font-size: 13px;
}
.btn_group button {
  background-color: #f12b2c;
  color: #fff;
  border-radius: 6px;
  padding: 8px 20px;
  border-style: none;
  margin-left: 3%;
  font-size: 15px;
  margin-bottom: 10px;
}
.go_on {
  float: left;
}
.go_on_wx {
  width: 90%;
}
.use {
  float: right;
  margin-right: 5%;
}
.bottom_foot {
  margin-top: 30px;
  width: 100%;
  padding: 0px 10%;
  font-size: 12px;
  color: #fff;
  text-align: left;
}
.bottom_foot_title {
  color: #ffe461;
  font-size: 14px;
  margin-bottom: 15px;
}
.bottom_foot p {
  line-height: 25px;
  padding-bottom: 20px;
}
@media screen and (max-width: 320px) {
  .pr_time {
    font-size: 12px;
  }
  .prLi_right {
    font-size: 13px;
  }
  .pr_con {
    font-size: 14px;
  }
}
.redColor {
  color: rgb(253, 94, 88);
}
</style>